My module contains attributes named "Comments_xx/xx/xxxx" which capture comments on a certain date. and I want to display all the comments attributes in a layoutDXL column. I could do it one by one but would rather dxl do it so i dont have to update the dxl every time i create a new comments column in the future. This code works but i need it to only grab the comments for the current object not all objects. I suspect the loop is wrong but when i disable the loop to go through the module i get errors. thanks for any help in advance
Module mod = current
Object o
AttrDef ad
for o in mod do {
for ad in mod do {
string sAttrName = ad.name
string str = "Comments"
if(matches(str, sAttrName))
{
if (ad.object)
{
display "\t" sAttrName o.sAttrName ""
}
}
}
display "\n"
}
bmohamed - Sun Jun 26 12:57:42 EDT 2016 |
Re: Layout DXL to combine comments Attributes in one column a) In layout DXL you have the predefined variable "obj", which points to the object for which the attribute is to be calculated. b) multiple "display" will not work. Instead, populate a variable in your loop and display at the end. In total this means that the following code should work (did not test)
Module mod = module obj
AttrDef ad
Buffer bufDisplay = create()
for ad in mod do {
string sAttrName = ad.name
string str = "Comments"
if(matches(str, sAttrName))
{
if (ad.object)
{
bufDisplay += "\t" + sAttrName + obj.sAttrName ""
}
}
}
display bufDisplay
delete bufDisplay
|
Re: Layout DXL to combine comments Attributes in one column Mike.Scharnow - Sun Jun 26 13:20:18 EDT 2016 a) In layout DXL you have the predefined variable "obj", which points to the object for which the attribute is to be calculated. b) multiple "display" will not work. Instead, populate a variable in your loop and display at the end. In total this means that the following code should work (did not test)
Module mod = module obj
AttrDef ad
Buffer bufDisplay = create()
for ad in mod do {
string sAttrName = ad.name
string str = "Comments"
if(matches(str, sAttrName))
{
if (ad.object)
{
bufDisplay += "\t" + sAttrName + obj.sAttrName ""
}
}
}
display bufDisplay
delete bufDisplay
I can't check right now, but I think multiple display work in layoutDXL, they will just add to each other with a newline? Doesn't work for ADXL though, since you need to actually set the attribute there. |
Re: Layout DXL to combine comments Attributes in one column O.Wilkop - Sun Jun 26 13:30:57 EDT 2016 I can't check right now, but I think multiple display work in layoutDXL, they will just add to each other with a newline? Doesn't work for ADXL though, since you need to actually set the attribute there. Thank you, @O.Wilkop b55fa187-906a-4430-9e09-5531b4f58329. You're right. So, @bmohamed 2352a5fb-27cf-4a2f-a128-1ca80c4b3477: only change the stuff about the obj variable and you should get what you want. |
Re: Layout DXL to combine comments Attributes in one column Mike.Scharnow - Sun Jun 26 13:20:18 EDT 2016 a) In layout DXL you have the predefined variable "obj", which points to the object for which the attribute is to be calculated. b) multiple "display" will not work. Instead, populate a variable in your loop and display at the end. In total this means that the following code should work (did not test)
Module mod = module obj
AttrDef ad
Buffer bufDisplay = create()
for ad in mod do {
string sAttrName = ad.name
string str = "Comments"
if(matches(str, sAttrName))
{
if (ad.object)
{
bufDisplay += "\t" + sAttrName + obj.sAttrName ""
}
}
}
display bufDisplay
delete bufDisplay
Thanks Mike. I'm getting this and not sure how to fix it. I tried a few things but my knowledge could be better working with buffers
-E- DXL: <Line:12> incorrect arguments for (+)
edit: one cool though, I got rid of Object o and change 'o' to 'obj' and it worked the same as before. I didnt know I could do that, thanks for the tip edit2: I did this and it seems to work with my code. I'm still curious about how i can get your code to work :)
Module mod = module obj
AttrDef ad
for ad in mod do {
string sAttrName = ad.name
string str = "Comment"
if(matches(str, sAttrName))
{
if (ad.object)
{
display "\t" sAttrName obj.sAttrName ""
}
}
}
display "\n"
|
Re: Layout DXL to combine comments Attributes in one column bmohamed - Mon Jun 27 18:40:58 EDT 2016 Thanks Mike. I'm getting this and not sure how to fix it. I tried a few things but my knowledge could be better working with buffers
-E- DXL: <Line:12> incorrect arguments for (+)
edit: one cool though, I got rid of Object o and change 'o' to 'obj' and it worked the same as before. I didnt know I could do that, thanks for the tip edit2: I did this and it seems to work with my code. I'm still curious about how i can get your code to work :)
Module mod = module obj
AttrDef ad
for ad in mod do {
string sAttrName = ad.name
string str = "Comment"
if(matches(str, sAttrName))
{
if (ad.object)
{
display "\t" sAttrName obj.sAttrName ""
}
}
}
display "\n"
Sorry, I mixed up possibilities of different languages - I should really have tested the code and I should work more actively with DXL. You could write it as bufDisplay +="\t" bufDisplay += sAttrName bufDisplay += obj.sAttrName "" But today, I am not so sure any more whether your own version will clutter the string table and whether my version is really better (in case you are interested, there is a discussion about this topic at https://www.ibm.com/developerworks/community/forums/html/topic?id=ee615bde-0eb3-4b54-9bd1-3cb6aa672989)
It might be interisting to have a look at the CatBuffer (see https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014656925)
as for the display, it should have said display tempStringOf bufDisplay Sorry for the confusion!! |
Re: Layout DXL to combine comments Attributes in one column bmohamed - Mon Jun 27 18:40:58 EDT 2016 Thanks Mike. I'm getting this and not sure how to fix it. I tried a few things but my knowledge could be better working with buffers
-E- DXL: <Line:12> incorrect arguments for (+)
edit: one cool though, I got rid of Object o and change 'o' to 'obj' and it worked the same as before. I didnt know I could do that, thanks for the tip edit2: I did this and it seems to work with my code. I'm still curious about how i can get your code to work :)
Module mod = module obj
AttrDef ad
for ad in mod do {
string sAttrName = ad.name
string str = "Comment"
if(matches(str, sAttrName))
{
if (ad.object)
{
display "\t" sAttrName obj.sAttrName ""
}
}
}
display "\n"
Oh, and you should really not use "Module mod = current", but "Module mod = module obj", meaning "take the module of the obj that is currently being calculated". This should be the same module usually, but if you have a lot of modules open at the same time, I am not sure whether the "current" module will always be set correctly. |
Re: Layout DXL to combine comments Attributes in one column Mike.Scharnow - Tue Jun 28 05:24:45 EDT 2016 Oh, and you should really not use "Module mod = current", but "Module mod = module obj", meaning "take the module of the obj that is currently being calculated". This should be the same module usually, but if you have a lot of modules open at the same time, I am not sure whether the "current" module will always be set correctly. Great...I'll make the change, thanks again |